package com.ihealthway.all.groupbuy.modules.admin;

import com.ihealthway.all.slog.annotation.SLog;
import com.ihealthway.all.commons.Constants;
import com.ihealthway.all.groupbuy.services.OrderInfoService;
import com.ihealthway.all.utils.Ajax;
import com.ihealthway.all.utils.AjaxReturn;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.POST;
import org.nutz.mvc.annotation.Param;

import java.util.Map;

/**
 * Goods module class
 * @author 凡梦星尘(elkan1788@gmail.com)
 */
@IocBean
@At("/admin/order")
public class OrderModule {

    private static final Log logger = Logs.get();

    @Inject
    private OrderInfoService orderInfoService;

    @At
    @Ok("beetl:admin/orderlist.jsp")
    public void index() {

    }

    @POST
    @At
    @SLog(module = Constants.MODULE_SHOP, type = Constants.OPERATE_TYPE_UPDATE, content = "审核【${args[0]}】订单的退款")
    public AjaxReturn refundPay(@Param("orderId") String orderIds) {
        AjaxReturn ar = Ajax.ok();
        boolean flag = orderInfoService.refundOrderPay(orderIds);
        if (!flag) {
            ar.setOk(false);
        }
        return ar;
    }

    @At
    public Map<String, Object> dataList(Integer rows, Integer page, @Param("orderId") String orderId,
                                        @Param("company") Integer companyId, @Param("orderStat") String orderStat,
                                        @Param("startD") String sDate, @Param("endD") String eDate) {

        return orderInfoService.getDataList(rows,page,orderId,companyId,orderStat,sDate,eDate);
    }
}
